package csel.model;

import junit.framework.Assert;
import junit.framework.TestCase;

import org.junit.After; 
import org.junit.Before; 
import org.junit.Test; 

public class UseableItemTester extends TestCase{
	
	UseableItem useableItem;
	public static void main(String args[]) 
	{ 
		junit.textui.TestRunner.run(MapTester.class); 
	} 

	@Before
	protected void setUp() throws Exception
	{
		useableItem = new Potion("potion");
	}

	@Test
	public void testPotions()
	{
		Entity e = new Entity(new GameGlobals(), new Summoner());
		useableItem.setTypeId("potion");
		useableItem.setCarriedBy(e);
		RealTile realTile = new RealTile();
		realTile.setLocation(new Location(2,2));
		useableItem.setLocation(realTile);
		e.setLocation(realTile);
		realTile.setItem(useableItem);
		int damage = 13;
		e.setLifeLeft(damage);
		useableItem.touch(e);
		Assert.assertEquals("potion", e.getInventory().dropUseableItem(useableItem).getTypeId());
		boolean isUsable = useableItem.use(e);
		if(isUsable)
		{
			Assert.assertEquals(damage-5, e.getLifeLeft());
		}
		
	}

	@After protected void tearDown() throws Exception 
	{ 
		super.tearDown();
	} 
}
